package com.myproject.sbp.base.common;

/**
 * 统一返回
 * @author ywh
 */
public class RespCommon {

    private String message;
    private String code;
    private Object data;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public RespCommon() {
    }

    public RespCommon(String code, String message, Object data) {
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public RespCommon(String code, String message) {
        this.message = message;
        this.code = code;
        this.data = null;
    }

    public static RespCommon result(RespEnum respEnum) {
        return new RespCommon(respEnum.getCode(), respEnum.getMessage());
    }

    public static RespCommon result(RespEnum respEnum, Object data) {
        return new RespCommon(respEnum.getCode(), respEnum.getMessage());
    }

    public static RespCommon result(String code, String message) {
        return new RespCommon(code, message);
    }

    public static RespCommon success(){
        return new RespCommon(RespEnum.SUCCESS.getCode(), RespEnum.SUCCESS.getMessage(), null);
    }

    public static RespCommon success(Object data){
        return new RespCommon(RespEnum.SUCCESS.getCode(), RespEnum.SUCCESS.getMessage(), data);
    }

    public static RespCommon error(){
        return new RespCommon(RespEnum.ERROR.getCode(), RespEnum.ERROR.getMessage(), null);
    }

}